<html>
	<head>
		<script type="text/javascript">
			function test(str) {
				var binaryString = "";
				var encodedString = "";
				var zeroString = "0000000";
				var appendString = "=="
				for(var i = 0; i < str.length; i++) {
					var binary = str.charCodeAt(i).toString(2);
					binaryString += zeroString.slice(0, 8 - binary.length) + binary;
				}
				binaryString += zeroString.slice(0, (binaryString.length%3 * 2));
				console.log(binaryString);

			}
		</script>
	</head>
<body onload="test('M')">
</body>
</html>